package edu.sctu.nieyu.day20150606.trainsystem;


/**
 * Created by user01 on 2015/6/6.
 */
public class PassengerInformationProcess {

    Passenger passenger0 = new PassengerData().passengerData().get(0);
    Passenger passenger1 = new PassengerData().passengerData().get(1);
    Passenger passenger2 = new PassengerData().passengerData().get(2);
    Passenger passenger[] = {passenger0, passenger1, passenger2};


    public void setPassenger() {


        for (int i = 0; i < passenger.length; i++) {
            System.out.println(passenger[i].getName());
            if (passenger[i].isIs_card()) {
                if (passenger[i].getCardName().equals("超级贵宾卡")) {
                    System.out.println("请进站！！");
                } else if (new Card.Luggage(passenger[i]).checkLuggage()) {
                    System.out.println("包裹存在安全问题，需进一步检查。");
                } else {
                    if (new Card.Luggage(passenger[i]).checkWater()) {
                        System.out.println("乘客所携带液体物品存在安全问题，需进一步检查！！");
                    } else {
                        if (passenger[i].getPrice() > 2) {
                            System.out.println("请进站！！");
                        } else {
                            System.out.println("请充值！！");
                            new Card().setPrice(10, passenger[i]);
                            System.out.println("充值成功，请进站！");
                        }
                        if (passenger[i].getPrice() >= new Card().getPrice(passenger[i].getStart(), passenger[i].getEnd())) {

                            System.out.println(passenger[i].getEnd() + "站到了，请有秩序下车！");

                            System.out.println("您本次消费：" + new Card().getPrice(passenger[i].getStart(), passenger[i].getEnd())
                                    + "\n您的天府通余额为：" + (passenger[i].getPrice() - new Card().getPrice(passenger[i].getStart(), passenger[i].getEnd())));
                            System.out.println("请出站，欢迎您再次乘坐本趟地铁！！");

                        } else {
                            System.out.println("请充值！");
                            new Card().setPrice(20, passenger[i]);
                            System.out.println("充值成功！请出站!");
                        }
                    }
                }
            } else {
                System.out.println("请购票！");
                if (new Card.Luggage(passenger[i]).checkLuggage()) {
                    System.out.println("包裹存在安全问题，需进一步检查。");
                } else {
                    if (new Card.Luggage(passenger[i]).checkWater()) {
                        System.out.println("乘客所携带液体物品存在安全问题，需进一步检查！！");
                    } else {
                        System.out.println("请出站并将您所购买的地铁单程票投入回收器中，欢迎您再次乘坐本趟地铁！");
                    }
                }

            }
        }

    }

    /**
     * 对发现的乘客的违法行为进行解决处理
     */
    protected void passengerAct() {
        for (int i = 0; i < passenger.length; i++) {
            if (passenger[i].isIs_action()) {
                if (new Action(passenger[i]).observeTrianAct()) {
                    System.out.println("乘客" + passenger[i].getName() + "存在违法行为,意欲强奸！，请执法人员立刻前往处置！！");
                } else {
                    System.out.println("一切正常，地铁内无异常情况！！");
                }

            }

        }
    }


}

